<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>无重复字符的最长子串</title>
</head>
<body>
  <script>
    function fn(s) {
      let arr = [], max = 0;
      for (let item of s) {
        while (arr.includes(item)) arr.shift()
        arr.push(item)
        max = Math.max(max, arr.length)
      }
      return max
    }
    console.log(fn("pwwkew"))
  </script>
</body>
</html>